home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / PGM_TOOL / TPRCDR10 / COUNT.PAS next >
Pascal/Delphi Source File  |  1993-12-26  |  2KB  |  64 lines

  1. { ╔═══════════╤════════════════════════════════════════════════╗
  2.   ║ Programmer│ Tony Papadimitriou                             ║
  3.   ║ Program   │ COUNT                                          ║
  4.   ║ Uses      │ Dos, TPUtils, TPRecDir                         ║
  5.   ║ Includes  │ Nothing                                        ║
  6.   ║ Links     │ Nothing                                        ║
  7.   ║ Created   │ Sunday, December 19, 1993  2:08 am             ║
  8.   ║ Updated   │ Saturday, December 25, 1993  3:50 pm           ║
  9.   ║ Language  │ (MSDOS) Turbo Pascal 6.0                       ║
  10.   ║ Purpose   │ Show off TPRecDir unit                         ║
  11.   ╟───────────┴┬──────── Version History ──────────────────────╢
  12.   ║ 1.00       │Original                                       ║
  13.   ╚════════════╧═══════════════════════════════════════════════╝ }
  14. uses
  15.   Dos,
  16.   TPUtils,
  17.   TPRecDir;
  18.  
  19. const
  20.   progName = 'COUNT';
  21.   version  = '1.00';
  22.  
  23. procedure Copyright;
  24. begin
  25.   Writeln(stderr);
  26.   Writeln(stderr,progName+' ver. ' + version + ' ■ Copyright (c) 1993-94 by Tony G. Papadimitriou *FREEWARE*');
  27.   Writeln(stderr);
  28. end; { Copyright }
  29.  
  30. var
  31.   totalMatches: Longint;
  32.  
  33. { --- this is the user routine whose address you must supply to ForEachFileIn }
  34. function List(rec: SearchRec): Boolean; far;
  35. begin
  36.   List := True;
  37.   ShowProgressHere;
  38.   if not AttributeMatches(rec.attr,Directory) then
  39.     Inc(totalMatches);
  40. end; { List }
  41.  
  42. var
  43.   path: PathStr;
  44.   mask: String;
  45. begin
  46.   Copyright;
  47.   if ParamCount = 0 then
  48.   begin
  49.     Writeln(stderr,'Usage: COUNT [<path>\]<mask>[;<mask>]');
  50.     Writeln(stderr);
  51.     Writeln(stderr,'       Press ESC during search to interrupt prematurely.');
  52.     Halt;
  53.   end; { if }
  54.   totalMatches := 0;
  55.   path := ParamStr(1);
  56.   mask := GetMask(path);
  57.   path := GetPath(path);
  58.   Write(stderr,'Working  ');
  59.   ForEachFileIn(path,mask,AnyFile,True,True,@List);
  60.   BlankLine;
  61.   if errorsFound then Writeln(stderr,'Errors during processing!');
  62.   Writeln(stderr,totalMatches,' match'+OneManyStr(totalMatches,'','es')+' found!');
  63. end.
  64.